<!DOCTYPE html>

<html >
<head>
    <meta charset="UTF-8">
    <title>控制台</title>
    <link rel="stylesheet" type="text/css" href="../layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../css/admin.css">
    <style>
        .imgWH{
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div style="width: 100%;height: 100%;position: relative;">
<div class="layui-carousel" id="test1" lay-filter="test1" style="height: 60%;height:60%;top: 10px;left: 10px;float: left;">
    <div carousel-item="">
        <div><img src="../img/2233.png" class="imgWH"></div>
        <div><img src="../img/狐妖02.jpg" class="imgWH"></div>
        <div><img src="../img/head.png" class="imgWH"></div>
        <div><img src="../img/狐妖03.jpg" class="imgWH"></div>
    </div>
</div>
    <div class="layui-card" style="width: 450px;height: 180px;top: 10px;right: 10px;float: right;position: relative;">
        <div class="layui-card-header">购退票比率</div>
        <div class="layui-card-body layadmin-takerates">
            <div class="layui-progress" lay-showpercent="yes">
                <h3>购票<span class="layui-edge" lay-tips="增长" lay-offset="-15"></span></h3>
                <div class="layui-progress" lay-filter="demoUp">
                    <div class="layui-progress-bar" lay-percent="" id="demoUp"></div>
                </div>
            </div>
            <div class="layui-progress" lay-showpercent="yes">
                <h3>退票 <span class="layui-edge" lay-tips="下降" lay-offset="-15"></span></h3>
                <div class="layui-progress"  lay-filter="demoDown">
                    <div class="layui-progress-bar" lay-percent="" id="demoDown"></div>
                </div>
            </div>
        </div>
    </div>
<div class="layui-card" style="height: 270px;width: 450px;top: 10px;float:right;right: 10px;position: relative;">
    <div class="layui-card-header" style="position: relative;top:0px;">日购票数</div>
    <div style="width: 430px;height: 250px;margin-left: 5px;margin-top: 5px;" id="table1"> </div>
</div>
</div>

</div>
<script type="text/javascript" src="../layui/layui.js"></script>
<!--<script src="../js/jquery-3.5.1.min.js"></script>-->
<script src="../js/jquery-3.5.1.js"></script>
<script src="../js/echarts.min.js"></script>
<script type="text/javascript" src="../js/adminHome.js"></script>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('table1'));
    // 指定图表的配置项和数据
    option = {
        title: {
            text: '数据图表'
        },
        color:'#00BFFF',
        tooltip: {},
        legend: {
            data:['数量']
        },
        xAxis: {
            data: []
        },
        yAxis: {},
        series: [{
            name: '时间',
            type: 'bar',
            data: []
        }]
    };
    myChart.setOption(option);
    myChart.showLoading();
    var names=[];    //类别数组（实际用来盛放X轴坐标值）
    var nums=[];    //销量数组（实际用来盛放Y坐标值）
    $.ajax({
        type : "post",
        async : true,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
        url : "/Ticket/ticketLogInfo/echarts",    //请求发送
        data : {},
        dataType : "json",        //返回数据形式为json
        success : function(res) {
            //请求成功时执行该函数内容，res即为服务器返回的json对象
            var list=eval(res.data);
            if (res.code ==0) {
                for(var i=0;i<list.length;i++){
                    names.push(list[i].name);    //挨个取出类别并填入类别数组
                }
                for(var i=0;i<list.length;i++){
                    nums.push(list[i].num);    //挨个取出销量并填入销量数组
                }
                // alert(names+nums);
                myChart.hideLoading();    //隐藏加载动画
                myChart.setOption({//加载数据图表
                    xAxis: {
                        data: names
                    },
                    series: [{
                        // 根据名字对应到相应的系列
                        name: '时间',
                        data: nums
                    }]
                });
            }
        },
        error : function(errorMsg) {
            //请求失败时执行该函数
            layer.msg("图表数据加载失败")
            myChart.hideLoading();
        }
    });
</script>
</body>
</html>
